<?php
/* @var $this XdvertController */
/* @var $model Xdvert */
/* @var $form CActiveForm */
Yii::app()->clientScript->registerCoreScript('jquery'); 

?> 
<script type="text/javascript">
    $(document).ready(function(e) {
       showview();
       $('#xdtype').change(function(){
       		showview();
       });
      
         $("#relevance").colorbox({
            href:"<?php echo Yii::app()->createUrl('xdvert/viewfile')?>",
            close: "【关闭】",
            initialWidth:600,
            initialHeight:500,
            width:'600px',
            height:'500px',
            title:"关联文件" 
           });

    });  
    function showview(){
    	var xdtype = $('#xdtype').val();
    	if(xdtype==0){
    		$('#videoview').attr('style','display:none;') 
    		$('#pictureview').attr('style','display:;')
    	}else{
    		$('#videoview').attr('style','display:;') 
    		$('#pictureview').attr('style','display:none;')
    	}
    }

      function callbacks(path){
        $('#picture').val(path); 
       }
</script>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'xdvert-form',
	'enableAjaxValidation'=>false,
	'htmlOptions' => array('enctype'=>'multipart/form-data'),
)); ?>

	<p class="note"><span class="required">*</span> 是必填内容.</p> 

	<?php //echo $form->errorSummary($model); ?>

	<div class="row">
		<?php if(Yii::app()->user->name=='admin'){?>  
			<?php echo $form->labelEx($model,'companyid'); ?>
			<?php echo $form->dropDownList(
	              $model,
	              'companyid', 
	            CHtml::listData(
	                Company::model()->findAll(),
	                'id',
	                'title'
	            )
	        ); ?> 
		
		<?php }else{
			echo $form->hiddenField($model,'companyid',array('value'=>Yii::app()->user->id));
		}?>
	</div>

    <div class="row">
        <?php echo $form->labelEx($model,'title'); ?>
          <?php echo $form->textField($model,'title');?> 
        <?php echo $form->error($model,'title'); ?>
    </div>

	<div class="row">
		<?php echo $form->labelEx($model,'xdtype'); ?>
		   <?php echo $form->dropDownList(
                  $model,
                  'xdtype',
                CHtml::listData(
                   $xdverttype,
                    'id',
                    'title'
                ),array('id'=>'xdtype')
            ); ?>
		<?php echo $form->error($model,'xdtype'); ?>
	</div>
 	  <div class="row" id="videoview" style="display: none;">

        <?php  echo CHtml::label(" ",false);?> 
        <?php echo  CHtml::button('关联文件',array('id'=>'relevance')); ?>
    </div>

	<div class="row">
		<?php echo $form->labelEx($model,'picture'); ?>
          <?php echo $form->textField($model,'picture',array('id'=>'picture'));?> 
		<?php echo $form->error($model,'picture'); ?>
	</div>

	 
	<div class="row">
		<?php echo $form->labelEx($model,'url'); ?>
		<?php echo $form->textField($model,'url',array('maxlength'=>126)); ?>
		<?php echo $form->error($model,'url'); ?>
	</div>

	<div class="row" >
		<?php echo $form->checkBox($model,'usable',array('style'=>'width:16px!important;')); ?>
		<?php echo $form->label($model,'usable'); ?>
		<?php echo $form->error($model,'usable'); ?>
	</div> 

    <div class="row" >
        <?php echo $form->checkBox($model,'synchronous',array('style'=>'width:16px!important;')); ?>
        <?php echo $form->label($model,'synchronous'); ?>
        <?php echo $form->error($model,'synchronous'); ?>
    </div> 
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? '新增' : '修改',array('class'=>'subButton')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->